# -*- Python -*-

# Configuration file for the 'lit' test runner.

import os

import lit.formats
import lit.util

# name: The name of this test suite.
config.name = 'dxilconv'

# Check that the object root is known.
te = getattr(config, 'te', None)
if te is None:
    # Otherwise, we haven't loaded the site specific configuration (the user is
    # probably trying to run on a test file directly, and either the site
    # configuration hasn't been created by the build system, or we are in an
    # out-of-tree build situation).

    # Check for 'dxilconv_site_config' user parameter, and use that if available.
    site_cfg = lit_config.params.get('dxilconv_site_config', None)
    if site_cfg and os.path.exists(site_cfg):
        lit_config.load_config(config, site_cfg)
        raise SystemExit

test_dll = os.path.join(config.llvm_obj_root, config.llvm_build_mode, 'bin', 'dxilconv-tests.dll')

hlsl_data_dir = os.path.join(config.llvm_src_root, 'projects', 'dxilconv', 'test')

test_dir = os.path.join(config.llvm_obj_root, config.llvm_build_mode, 'test')

param_hlsl_data_dir = str.format('HlslDataDir={}', hlsl_data_dir)
extra_params = ['/p:', param_hlsl_data_dir]

verbose = bool(getattr(config, 'verbose', False))
if verbose != True:
    extra_params.append('/logOutput:')
    extra_params.append('LowWithConsoleBuffering')

arch = getattr(config, 'taef_arch', None)
select_filter = str.format("@Architecture='{}'", arch)

config.test_format = lit.formats.TaefTest(config.te, test_dll, test_dir, select_filter, extra_params)

